<?php
namespace app\home\model;
use think\Model;

class SubjectModel extends Model
{
	protected $table  = 'qm_subject';


	/**
	*
	*查找所有学科
	**/
	public function getSubjectAll($field = '*')
	{
		$list = $this->where('status','=', 1)->field($field)->order('sort DESC')->select();
		if(!empty($list))
		{
			$list = $list->toArray();
		}

		return $list;
	}


	/**
	*
	*根据学科ID，找出对应的学科信息
	**/
	public function getWhereSubjectIdList($subject_id, $field = '*')
	{
		//如果数组
		if(is_array($subject_id)){
			$list = $this->where('id', 'in', $subject_id)->where('status','=', 1)->order('sort DESC')->field($field)->select();
		}else{
			$list = $this->where('id', '=', $subject_id)->where('status','=', 1)->order('sort DESC')->field($field)->select();
		}

		if(!empty($list))
		{
			$list = $list->toArray();
		}

		return $list;
	}
}
